package leetcode.easy;


public class $35_SearchInsert {
    public int searchInsert(int[] nums, int target) {
        int start = 0;
        int end = nums.length - 1;
        while (start <= end) {
            int mid = (start + end) >> 1;
            if (target == nums[mid]) {
                return  mid;
            } else if (target < nums[mid]) {
                    end = mid - 1;
            } else {
                    start = mid + 1;
            }
        }
        return start;
    }
}
